#include<iostream>
using namespace std;

void del(string s, string a)
{
	bool flag = 1;
	for (int i = 0; s[i] != '\0'; i++)
	{
		if (s[i] != a[0])
		{
			flag = 0;
		}
	}
	for (int i = 0; s[i] != '\0'&&!flag; i++)
	{
		if (s[i] != a[0])
		{
			cout << s[i];
		}
	}
	if (flag)
	{
		cout << "NULL";
	}
}


int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		string s, a;
		cin >> s >> a;
		del(s, a);
		cout << endl;
	}

	return 0;
}